# -*- coding: utf-8 -*-
"""
@Project: Msptest
@Author: 余振新
@File name: 申请_科室会_医院组.py
@Create time: 2023/6/28 15:14
"""

from business.首页.会议管理系统.会前.会议申请.公共 import Public
from common.base_action import BaseAction
from common.base_driver import BaseDriver
from common.gol import get_value
from common.path import ensure_path_sep
from common.read_yaml import read_yaml
from page.首页.会议管理系统.会前.会议申请列表 import 列表页, 科室会推广, 公共

data = read_yaml()["meeting"]
text = data["text"]
photo_path = ensure_path_sep(data["photo_path"])
pdf_path = ensure_path_sep(data["pdf_path"])


class RequestMeeting(BaseAction):
    def __init__(self, driver):
        super().__init__(driver)  # 调用父类的 __init__ 方法来初始化实例变量

    def 申请_科室会推广(self):
        public = Public(self.driver)
        public.打开_会前_会议申请(列表页.会议申请_科室会推广)
        public.基本信息_会议时间()
        public.基本信息_关联终端()
        public.参会科室()
        public.基本信息_会议地点()
        self.click(公共.服务平台及主题_添加按钮)
        self.click(科室会推广.服务平台及主题_第一个)
        self.sendkey_end()
        self.click_all(公共.服务平台及主题_确认按钮)
        self.click(公共.讲师信息_添加按钮)
        self.click(公共.讲师信息_选择讲师)
        self.click(科室会推广.讲师信息_选择讲师_最后一个)
        self.sendkey_end()
        self.click(公共.讲师信息_选择讲师_保存)
        self.send_keys(科室会推广.议题, text)
        script = '''var element = document.querySelector("body > div:nth-child(18) > div.ivu-modal-wrap.vertical-center-modal > div > div > div.ivu-modal-body > div.ivu-row > form > div.ivu-form-item.ivu-form-item-required.ivu-form-item-error > div > div.ivu-row > div.ivu-date-picker > div.ivu-date-picker-rel > div > div > input");
                        if (element)
                            {
                                element.removeAttribute("readonly");
                            }'''
        self.driver.execute_script(script)
        self.send_keys(科室会推广.议题时间, "2029-11-01 00:00:00 - 2029-11-02 00:00:00")
        self.click(公共.讲师信息_保存按钮)
        return public.断言_会议申请从下一步到保存的操作是否成功_有参会人()


if __name__ == '__main__':
    BaseDriver().get_driver(_browser="chrome", _url="https://test-home.cxjk.com/#/center_home")
    RequestMeeting(get_value("driver")).申请_科室会推广()
    # ReviewMeeting(get_value("driver")).会议一审()
